package com.hnguigu.health.houduan.lcj.controller_lcj;

import com.hnguigu.health.houduan.lcj.pojo_lcj.TMember_lcj;
import com.hnguigu.health.houduan.lcj.service_lcj.TMemberService_lcj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/tmem")
public class TMemberController_lcj {

    @Autowired(required = false)
    TMemberService_lcj tmems;

    @GetMapping("/getByname")
    @ResponseBody
    public TMember_lcj getByname(String name){
        List<TMember_lcj> byName = tmems.getByName(name);
        if(byName.size()>1){
            TMember_lcj tMember_lcj = new TMember_lcj();
            tMember_lcj.setId(0);
            return tMember_lcj;
        }else if(byName.size()==0){
            return null;
        }else{
            return byName.get(0);
        }

    }
}
